﻿<template>
  <div v-if = "show">
    <div v-if="formItemConfig.category === 'dComponent'">
      <component v-bind:is="formItemConfig.componentName+'Config'" :config.sync="formItemConfig.config" :events.sync="formItemConfig.events"></component>
    </div>
  </div>
</template>

<script>
import EventDic from '@/components/Events/EventsDic.vue'
export default {
  components: {
    EventDic
  },
  props: ['formItemConfig', 'formDataList'],
  data () {
    return {
      // 所有的事件
      allEvents: []
    }
  },
  computed: {
    show () {
      if (this.formItemConfig && Object.keys(this.formItemConfig).length > 0) {
        this.getAllEvents()
        return true
      }
      return false
    }
  },
  methods: {
    // 获取所有的动态表单事件
    getAllEvents () {
      this.allEvents = this.$store.state.commonData.apiEvents
    }
  },
  watch: {
    'formItemConfig.config': {
      handler: function (val, oldVal) {
        this.config = val
      },
      deep: true
    }
  }
}
</script>
